package guiobjects;

import java.awt.Color;
import java.util.Scanner;

/**
 * Draws a circle.
 * 
 * @author Trevor Terris
 *
 */
public class Circle implements IPaintedObject
{
	private int radius;
	private double xCoord;
	private double yCoord;
	private Color myColor = Color.black;
	public void parseText(String input)
	{
		Scanner s = new Scanner(input);
		xCoord = s.nextDouble();
		yCoord = s.nextDouble();
		radius = s.nextInt();
		if (s.hasNextInt())
		{
			myColor = new Color(s.nextInt(), s.nextInt(), s.nextInt());
		}
	}
	public void drawObject(java.awt.Graphics pen, int screenWidth, int screenHeight, int offset)
	{
		pen.setColor(myColor);
		pen.fillOval((int)(xCoord * screenWidth - radius) + offset, (int)(yCoord * screenHeight - radius), radius * 2, radius * 2);
	}
	public String getSVGData(int width, int offset, int total)
	{
		String output = "<circle cx=\"";
		double xValue = (((double)offset + (double)width * xCoord) * 100.0 / (double) total);
		
		output += xValue + "%\" cy=\"";
		double yValue = (yCoord * 100.0);
		output += yValue + "%\" r=\"" + radius + "\" style=\"fill:rgb(" + myColor.getRed() + "," + 
					myColor.getGreen() + "," + myColor.getBlue() + ");\"/>";
		
		return output;
	}
}
